package org.example.spring.poi.controller;

import lombok.RequiredArgsConstructor;
import org.example.spring.poi.model.entity.SysUser;
import org.example.spring.poi.service.CommonTransactionService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author hzq
 * @since 2022/6/15
 */
@RestController
@RequestMapping("/sysUser")
@RequiredArgsConstructor
public class SysUserController {

    private final CommonTransactionService commonTransactionService;

    @PostMapping
    public SysUser add(@RequestBody @Valid SysUser sysUser) {
        return commonTransactionService.add(sysUser);
    }

    @PostMapping("/save")
    public SysUser save(@RequestBody @Valid SysUser sysUser) {
        return commonTransactionService.addTransactional(sysUser);
    }
}
